package utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class AppPreferences {
	
	private static String PREF_NAME = "wc_pref";
	public static String ACCESS_TOKEN = "access_token";
	public static String USER_ID = "user_id";
	
	public static void setAppSharedPref(Context context, String access_token, String user_id) {
		SharedPreferences sharedPref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
		Editor editor = sharedPref.edit();
		editor.putString(ACCESS_TOKEN, access_token);
		editor.putString(USER_ID, user_id);
		editor.commit();
	}
	
	public static String getTokenValue(Context context) {
		SharedPreferences sharedPref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
		return sharedPref.getString(ACCESS_TOKEN, null);
	}
	
	public static String getUserIdValue(Context context) {
		SharedPreferences sharedPref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
		return sharedPref.getString(USER_ID, null);
	}
	
	public static void clearPref(Context context) {
		SharedPreferences sharedPref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
		Editor editor = sharedPref.edit();
		editor.clear();
		editor.commit();
	}
}
